pmiab (Poor Man's Internet Ad Blocker) is a simple bash script that blocks ads and other unwanted nasty stuff and makes surfing the ocean of Internet faster, better and safer experience. pmiab does this with the help of hosts file. Using hosts file to block ads has several distinct advantages over other ad-blocking methods.
- No need to install and run any other applications.
- Saves CPU, RAM and bandwidth.
- Blocks IP calls on any port.
- Faster web-page loading.
- Enhances your privacy & security.
- Hosts file can be edited in any text editor.
- Works with any and every browser.
pmiab downloads ad-blocking hosts files from the following sources,
- MPVS hosts file
- Dan Pollock's hosts file
- yoyo.org hosts file
- Badd Boyz hosts file
- Steven Black's hosts file
- ABUSE.ch hosts file
- AdAway hosts file
Then pmiab does some bash magic,
- Creates a backup of original hosts file and sets it to read-only.
- Removes MS-DOS carriage returns.
- Removes all lines that don't begin with 127.0.0.1.
- Removes any lines containing the word localhost.
- Replaces 127.0.0.1 with 0.0.0.0.
- Scrunches extraneous spaces into a single tab.
- Removes any comments on lines.
- Cleans leftover trailing blanks.
- Removes duplicate entries.
- Creates an ultimate ad-blocking hosts file.
Installation is very simple. Download pmiab-master zip, extract its contents and copy the file pmiab to /usr/local/bin/ directory,
sudo cp pmiab /usr/local/bin/
And make it executable,
sudo chmod 755 /usr/local/bin/pmiab
Since pmiab deals with the hosts file it needs to be run with sudo. Open terminal & run,
sudo pmiab
Or if you prefer su over sudo,
su -c pmiab
Then you can enable or disable advert blocking via a simple interactive menu of pmiab. To block the ads, select Block Internet Adverts option from the menu. Restart your browser if it is running, clean browser's cache and enjoy a smoother, safer and ad-free browsing. It is advised that you update the ad-blocking hosts file atleast once in a week. To update the ad-blocking hosts, you need to simply select Block Internet Adverts option from the menu.
If you like pmiab, please consider supporting it, even the smallest contribution goes a long way. It is quick & easy via PayPal, Buy Me a Coffee or Liberapay:
- Steve Riley : This script originally was a brainchild of Steve. Incredibly this was the first bash script he wrote.
- Stuart Hanzlik : Stuarts articles on hosts file and its usage as ad blocker provided some valuable information.
This work (pmiab, by hakerdefo), identified by hakerdefo, is free of known copyright restrictions.